package com.sfx.mq.consumer.lisener;

import com.sfx.mq.consumer.constants.TopicProperties;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-10-28
 * Time: 18:25
 */
@Component
@RocketMQMessageListener(topic = "tagTopic",
        consumerGroup = "consumer-tag-group",
        consumeMode = ConsumeMode.CONCURRENTLY,
        selectorType = SelectorType.TAG,
        selectorExpression = "TagA || TagB"
)
public class RocketMQConsumerListener implements RocketMQListener<Message> {
    @Override
    public void onMessage(Message message) {
        System.out.println("message : " + new String(message.getBody())
        + "  消息的key : " + message.getKeys() + " 消息的tag : " + message.getTags());
    }
}